package com.qs.education.bean.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.qs.education.bean.dao.IEducationHomeWorkDao;
import com.qs.education.bean.entity.EducationHomeWork;
import com.qs.education.bean.entity.EducationQuestion;

/**
 * @class EducationHomeWorkDaoImpl
 * @author Leon
 * @description
 * @date Nov 22, 2018
 */
@Service
public class EducationHomeWorkDaoImpl extends BaseDaoImpl<EducationHomeWork> implements IEducationHomeWorkDao {

	@Override
	public List<EducationQuestion> getQuestionByIds(List<Long> ids) {
		String jql = "Select ea from EducationQuestion ea where ea.id in :ids";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ids", ids);
		List<EducationQuestion> questions = query(jql, EducationQuestion.class, params);
		return questions;
	}

	@Override
	public List<EducationHomeWork> findHomeWorkByTeacherId(String teacherId) {
		String jql = "Select ea from EducationHomeWork ea where ea.teacher.id = :id";
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("id", Integer.parseInt(teacherId));
		List<EducationHomeWork> homeworks = query(jql, EducationHomeWork.class, params);
		return homeworks;
	}
}
